Golang : How to force compile or remove object files first before rebuild?
Problem :
You want to use rebuild or refresh your Golang program every time there is a change on any of the source files in your project. Basically, you want to remove the .a
(object) files "first" in the pkg
directory in your workspace each time when there is a rebuild. How to do that ?
Solutions :
In the go build
command, there is a -a
flag that you can use to refresh/rebuild or recompile everything packages that are already up-to-date.
For example :
>go build -a program-name
or you can issue the command
>go clean
first before executing go build
See also : Golang : Build and compile multiple source files
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+5.9k Golang : Dealing with backquote
+16.9k Golang : How to tell if a file is compressed either gzip or zip ?
+9k Golang : How to get garbage collection data?
+21.5k Golang : Use TLS version 1.2 and enforce server security configuration over client
+20.7k Golang : How to force compile or remove object files first before rebuild?
+6.6k Fix sudo yum hang problem with no output or error messages
+5.5k Golang : ROT32768 (rotate by 0x80) UTF-8 strings example
+18.9k Golang : Check if directory exist and create if does not exist
+7.1k Golang : Check to see if *File is a file or directory
+12.8k Golang : Handle or parse date string with Z suffix(RFC3339) example
+13.6k Golang : convert(cast) string to float value
+5.8k Golang : Experimenting with the Rejang script